<?php
    session_start();
    require 'class/user.class.php';

    $userName = $_POST["username"];
    $userPwd  = $_POST["psw"];
    $userFB = $_REQUEST['fbID'];
    $_SESSION['user'] = null;
    echo "name : ".$userName."<br/>userPwd : ".$userPwd."<br/>";
    if(isset($userName, $userPwd)) {
            //$user = new User(1, 'hippo', 'Do Ngoc Ha', 'hippo@gmail.com');
            $user = User::login($userName, $userPwd);
            print_r($user);
            //test
            if($user != null){
                if (isset($userFB))
                    $userID = $user->userID;
                USer::updateUserFacebook($userID, $userFB);
                $_SESSION['user'] = serialize($user);
                header("location: index.php");
                exit();
            }               
            else{//cannot retrive data from database
                
                //echo "password or name is error";
		header("location: index.php?login=fail");
               // exit();
            }
    }
    else {//unset user name or password
    }
